/**
 * 
 */
package com.tianbing.adlottery.json;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.web.servlet.view.AbstractView;

/**
 * @author Conan
 *
 */
public class AjaxJsonView extends AbstractView {

	/* (non-Javadoc)
	 * @see org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void renderMergedOutputModel(Map map, HttpServletRequest arg1, HttpServletResponse response)
			throws Exception {
		response.setContentType("text/plain; charset=UTF-8");
		// Set standard HTTP/1.1 no-cache headers.  
		response.setHeader("Cache-Control", "no-store, max-age=0, no-cache, must-revalidate");

		// Set IE extended HTTP/1.1 no-cache headers.  
		response.addHeader("Cache-Control", "post-check=0, pre-check=0");

		// Set standard HTTP/1.0 no-cache header.  
		response.setHeader("Pragma", "no-cache");
		JSONArray jsonArray = (JSONArray) map.get("ajax_json");
		response.getWriter().write(jsonArray.toString());
	}
}
